﻿<%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation="false" CodeBehind="Ckgl_Add.aspx.cs"
    Inherits="Catering.Catering_Page.Kufang.Ckgl_Add" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../Style/head.css" />
    <link rel="stylesheet" type="text/css" href="../../Style/center.css" />
    <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="../../Style/xxk.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript" src="../../Scripts/My97DatePicker/WdatePicker.js"></script>
    <style type="text/css">
        .Create_Recipe
        {
            margin-top: 0;
        }
        .Create_Recipe
        {
            border: 1px solid #159aec;
            border-top: none;
            width: 998px;
        }
        .soso_lt
        {
            padding: 5px 0;
        }
        .soso_lt a
        {
            margin-left: 3px;
        }
        .style3
        {
            height: 21px;
        }
        .style4
        {
            width: 112px;
        }
        .div_120
        {
            padding-top: 5px;
            background-color: #e5f1ff;
        }
        .div_120 ul
        {
            width: 996px;
            clear: both;
        }
        .div_120 li
        {
            float: left;
            height: 25px;
            line-height: 25px;
            margin-left: 10px;
        }
        .div_120 span
        {
            text-align: left;
            display: -moz-inline-box;
            display: inline-block;
            width: 60px;
        }
        .rkgl_search{height:40px; width:998px; margin:0px; padding:0px;}
        .rkgl_search td{height:40px; line-height:30px; vertical-align:middle;}
        .swxx_table th{color: #0760ac; font-size:13px; font-weight:bold; background-image: url(../../Images/table_th_bg.gif); border-bottom: px; text-align:center; border-left:0px; line-height: 32px; height: 32px;}
        .swxx_table tbody td{ border-bottom: #b0b0b0 1px dashed; text-align: center; border-left: 0px; line-height: 28px; height: 28px; border-top: 0px; border-right: 0px; overflow:hidden; padding:0px; margin:0px; }
        .swxx_table tbody td input {width:60px;}
        .ckinfo_add{width:798px; height:278px; border:1px solid #c2def6;}
        .ckinfo_add h1{ font-size:14px; height:27px; line-height:27px; padding-left:10px; color:#1d67c0; background:url(../../Images/div_h1_bg.gif) 0 0 repeat-x;}
        .ckinfo_add h1 img{ float:left; margin-right:5px; position:relative; top:5px;*top:4px;_top:4px;}
        .ckinfo_add td{ padding:6px 0px;}
    </style>
    <script type="text/javascript">
        var EditState = 0;

        function EditNumber(obj, objid) {
            if (EditState != 0 && ISQuXiao()) {
                QuXiao(EditState);
            }
            if (!obj) return;
            var value = obj.innerText;
            if (EditState == 0 || EditState == objid) {
                obj.outerHTML = "<input type='text' id='Number_" + objid + "' value=''/>";
                document.getElementById("Number_" + objid).focus();
                EditState = objid;
                var czobj = document.getElementById("CkglTools_" + objid);
                if (czobj) czobj.style.display = "block";
            }
            else {
                alert("您还有尚未保存的项！");
            }
        }

        function CheckAddOption() {
            if (isNaN(EditState) || EditState == 0) {
                alert("参数错误！");
                return false;
            }
            var number = document.getElementById("Number_" + EditState).value;
            if (!number || isNaN(number) || number <= 0) {
                alert("数量必须是大于0的数字！");
                return false;
            }
            $("#HF_Number").val(number);
            return true;
        }

        function QuXiao(objid) {
            EditState = 0;
            var number = document.getElementById("Number_" + objid);
            var CkglTools = document.getElementById("CkglTools_" + objid);
            if (number) {
                number.outerHTML = "<a title='单击编辑数量' onclick=\"EditNumber(this,'" + objid + "')\">编辑数量</a>";
            }
            if (CkglTools) {
                CkglTools.style.display = "none";
            }
        }

        function ISQuXiao() {
            var number = document.getElementById("Number_" + EditState).value;
            if (!number || isNaN(number) || number <= 0) {
                return true;
            }
            return false;
        }
        function CheckModel() {
            if ($("#Txt_AddDate").val() == "") {
                alert("请输入入库日期！");
                return false;
            }
            return true;
        }
        function CheckModel() {
            if ($("#Txt_AddDate").val() == "") {
                alert("请输入入库日期！");
                return false;
            }
            return true;
        }

        function AddChuku(id) {
            if (!CheckAddOption()) return;
            var number = document.getElementById("Number_" + EditState).value;
            var addDate = $("#Txt_AddDate").val();
            $.ajax({
                type: "Post",
                url: "Ckgl_Add.aspx/AddChuKu",
                data: "{'StrID':'" + id + "','Number':'" + number + "','StrAddDate':'" + addDate + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d[0] == "OK") {
                        $("#InputDataBaseInfo tr[optionid=" + id + "]").remove();
                        QuXiao(id);
                        alert("添加成功");
                    }
                    else {
                        alert(data.d[0]);
                    }
                }
            });
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:HiddenField ID="HF_Number" runat="server" Value="0" />
    <div class="Center_Content" id="div2_1" style="display: block">
        <div style="width: 1000px; background-color: #FFFFFF; position:fixed; top:0px;">
            <div style="height: 40px; width: 998px; background-color: #E5F1FF; border: 1px solid #C2DEF6;
                margin:10px 0px;">
                <table border="0" cellpadding="0" cellspacing="0" class="rkgl_search">
                    <tr>
                        <td width="56" align="right">
                            作业区：
                        </td>
                        <td width="90">
                            <asp:DropDownList ID="DDL_zuoyequ" Enabled="false" CssClass="select_input_bg" runat="server"
                                AutoPostBack="true" Width="85px">
                            </asp:DropDownList>
                        </td>
                        <td width="40" align="right">
                            班组：
                        </td>
                        <td width="85">
                            <asp:DropDownList ID="DDL_banzu" Enabled="false" runat="server" Width="80px" CssClass="select_input_bg">
                            </asp:DropDownList>
                        </td>
                        <td width="85">
                            <asp:DropDownList ID="DDL_Type1" AutoPostBack="true" runat="server" Width="80px"
                                CssClass="select_input_bg" OnSelectedIndexChanged="DDL_Type1_SelectedIndexChanged">
                            </asp:DropDownList>
                        </td>
                        <td width="85">
                            <asp:DropDownList ID="DDL_Type2" AutoPostBack="true" runat="server" Width="80px"
                                CssClass="select_input_bg">
                            </asp:DropDownList>
                        </td>
                        <td width="80" align="center">
                            <asp:DropDownList ID="DDL_SearchType" Width="75" CssClass="select_input_bg" AutoPostBack="true"
                                runat="server" OnSelectedIndexChanged="DDL_SearchType_SelectedIndexChanged">
                                <asp:ListItem Value="0">模板日期</asp:ListItem>
                                <asp:ListItem Value="1">品号</asp:ListItem>
                                <asp:ListItem Value="2">名称</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                        <td width="75">
                            <asp:TextBox ID="Txt_MBDate" CssClass="input_bg" Width="70px" runat="server"></asp:TextBox>
                        </td>
                        <td width="70" align="right">
                            出库日期：
                        </td>
                        <td width="75">
                            <asp:TextBox ID="Txt_AddDate" CssClass="input_bg" Width="70px" runat="server"></asp:TextBox>
                        </td>
                        <td width="90">
                            <asp:Button ID="Btn_Search" CssClass="input_btn_a" runat="server" Text="确认模板" OnClick="Btn_Search_Click"
                                OnClientClick="return CheckModel()" />
                        </td>
                        <td width="90">
                            <asp:Button ID="Btn_Excel" CssClass="input_btn_a" runat="server" Text="导出Excel" OnClick="Btn_Excel_Click" />
                        </td>
                        <td>
                            &nbsp;
                        </td>
                        <td align="right" width="80">
                            <asp:LinkButton ID="LB_Return" CssClass="input_btn_a" runat="server">返　回</asp:LinkButton>
                        </td>
                        <td width="10">
                            &nbsp;
                        </td>
                    </tr>
                </table>
            </div>
            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="swxx_table">
                <thead>
                    <tr>
                        <th style="width: 9%">
                            序号
                        </th>
                        <th style="width: 10%">
                            原料大类
                        </th>
                        <th style="width: 9%">
                            原料细类
                        </th>
                        <th style="width: 9%">
                            品号
                        </th>
                        <th style="width: 10%">
                            品名
                        </th>
                        <th style="width: 9%">
                            单价
                        </th>
                        <th style="width: 9%">
                            数量
                        </th>
                        <th style="width: 9%">
                            可出库量
                        </th>
                        <th style="width: 9%">
                            警戒线
                        </th>
                        <th style="width: 9%">
                            单位
                        </th>
                        <th style="width: 9%">
                            操作
                        </th>
                    </tr>
                </thead>
            </table>
        </div>
        <div style="height:62px; clear: both;">
        </div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <div style="width: 998px; border: #B0B0B0 1px solid; border-bottom: none; border-top: none;">
                    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="swxx_table">
                        <thead>
                    <tr>
                        <th style="width: 9%">
                            序号
                        </th>
                        <th style="width: 10%">
                            原料大类
                        </th>
                        <th style="width: 9%">
                            原料细类
                        </th>
                        <th style="width: 9%">
                            品号
                        </th>
                        <th style="width: 10%">
                            品名
                        </th>
                        <th style="width: 9%">
                            单价
                        </th>
                        <th style="width: 9%">
                            数量
                        </th>
                        <th style="width: 9%">
                            可出库量
                        </th>
                        <th style="width: 9%">
                            警戒线
                        </th>
                        <th style="width: 9%">
                            单位
                        </th>
                        <th style="width: 9%">
                            操作
                        </th>
                    </tr>
                </thead>                    
                        <tbody id="InputDataBaseInfo">
                            <asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand">
                                <ItemTemplate>
                                    <tr optionid="<%#Eval("id")%>" style="background: #ffffff" onmouseover="this.style.background='#E3F5FF'" onmouseout="this.style.background='#FFFFFF'">
                                        <td>
                                            <%# GetXuNiIndex()%>
                                        </td>
                                        <td>
                                            <%# Eval("RTName")%>
                                        </td>
                                        <td>
                                            <%# Eval("RInfoName")%>
                                        </td>
                                        <td>
                                            <%# Eval("InDBid") %>
                                        </td>
                                        <td>
                                            <%# Eval("RAWName") %>
                                        </td>
                                        <td>
                                            <%# Eval("Price") %>
                                        </td>
                                        <td>
                                            <a title="单击编辑数量" onclick="EditNumber(this,'<%# Eval("id") %>')">编辑数量</a>
                                        </td>
                                        <td>
                                            <%#this.GetKCNumber(Eval("InDBid").ToString())%>
                                        </td>
                                        <td>
                                            <%#this.GetKCWaring(Eval("RAWID").ToString())%>
                                        </td>
                                        <td>
                                            <%# Eval("CMP") %>
                                        </td>
                                        <td>
                                            <table>
                                                <tr id="CkglTools_<%# Eval("id") %>" style="display: none;">
                                                    <td height="24" style="border-bottom: none;">
                                                        <a href="javascript:QuXiao('<%#Eval("id")%>')">取消</a>
                                                    </td>
                                                    <td width="10" style="border-bottom: none;">
                                                        &nbsp;
                                                    </td>
                                                    <td style="border-bottom: none;">
                                                        <a href="javascript:AddChuku('<%#Eval("id")%>')">保存</a>                                                        
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </ItemTemplate>
                            </asp:Repeater>
                            <tr>
                                <td colspan="11">
                                    <asp:Button ID="Btn_Pre" runat="server" Text="上一页" onclick="Btn_Pre_Click" />
                                    <asp:Label ID="Label1" runat="server" Text="1"></asp:Label>
                                    <asp:Button ID="Btn_Nex" runat="server" Text="下一页" onclick="Btn_Nex_Click" />
                                    <asp:HiddenField ID="HF_CurrentIndex" runat="server" Value="1" />
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    <div class="footer">
        <strong>中海油能源发展配餐服务公司渤海自营油田作业公司&nbsp;&nbsp;版权所有@CopyRight 2012</strong><span>技术支持：北京天择嘉业科技有限公司</span></div>
    </form>
</body>
</html>
